using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using HuiLian.Common.Input;
using HuiLian.Common.Output;
using HuiLian.Model.Platform;
using HuiLian.Service.Platform.CallTime;
using HuiLian.Service.Platform.CallTime.Input;

namespace HuiLian.Web.Controllers.Platform
{
    /// <summary>
    /// 模型执行记录管理
    /// </summary>
    public class CallTimeController : AreaController
    {
        private readonly ICallTimeService _callTimeServices;

        public CallTimeController(ICallTimeService callTimeServices)
        {
            _callTimeServices = callTimeServices;
        }

        /// <summary>
        /// 查询单条模型执行记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> Get(long id)
        {
            return await _callTimeServices.GetAsync(id);
        }

        /// <summary>
        /// 查询分页模型执行记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> GetPage(PageInput<CallTimeEntity> model)
        {
            return await _callTimeServices.PageAsync(model);
        }

        /// <summary>
        /// 新增模型执行记录
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> Add(CallTimeAddInput input)
        {
            return await _callTimeServices.AddAsync(input);
        }

        /// <summary>
        /// 修改模型执行记录
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> Update(CallTimeUpdateInput input)
        {
            return await _callTimeServices.UpdateAsync(input);
        }

        /// <summary>
        /// 删除模型执行记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IResponseOutput> SoftDelete(long id)
        {
            return await _callTimeServices.SoftDeleteAsync(id);
        }

        /// <summary>
        /// 批量删除模型执行记录
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> BatchSoftDelete(long[] ids)
        {
            return await _callTimeServices.BatchSoftDeleteAsync(ids);
        }
    }
}
